import { Component} from '@angular/core';
import { NavController,IonicPage,NavParams} from 'ionic-angular';
import { Http} from '@angular/http';
@IonicPage()
@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
  select : number;
  public list =[];
  public menuShow = false;
  public logoList = '../../assets/imgs/cuLogo/logo@2x.png';
  public registerList=[];
  topBag: string = '../../assets/imgs/banner@2x.png';
  logo: string = '../../assets/imgs/logo.png';
  public addressCard=[
    {"title" : "自己有地址","content" :"中禄帮您高效代办窗口关系取证快递","btnText" : "立即咨询"},
    {"title" : "自己无地址","content" :"中禄提供稳定地址后期财务专业服务","btnText" : "立即咨询"},
  ];
  login: { username: string, phone: string } = {
    username: '',
    phone: '',
  };
  constructor(public navCtrl: NavController, private http : Http,public params:NavParams) {
    let elements = document.querySelectorAll(".tabbar");
    if(elements != null) {
      Object.keys(elements).map((key) => {
        elements[key].style.display ='none';
      });
    }
    this.list=[
      {"id" : 1,"fun" :"goRegister", "name":"公司注册"},
      {"id" : 2,"fun" :"goLicenseagent", "name":"营业执照代办"},
      {"id" : 3,"fun" :"goLogout", "name":"公司注销"},
      {"id" : 4,"fun" :"goCompanyChange", "name":"公司变更"},
    ]
    this.registerList = [
      {"id":1,"imgurl" : "../../assets/imgs/hmIcon.png","content" :"核名"},
      {"id":2,"imgurl" : "../../assets/imgs/ziliao_icon@2x.png","content" :"提交资料"},
      {"id":3,"imgurl" : "../../assets/imgs/gongshang_icon@2x.png","content" :"工商登记"},
      {"id":4,"imgurl" : "../../assets/imgs/zhizhao_icon@2x.png","content" :"领取执照"},
    ];
  }
  /*************************页面跳转start*************************/
  goServiceCase(){
    this.navCtrl.push('ServicecasePage');//服务案例
  }
  /*************************页面跳转 end*************************/
  isNull(str) {
    if(str === "" || str == undefined)
      return true;
    var regu = "^[ ]+$";
    var re = new RegExp(regu);
    return re.test(str);
  }
  checkMobile(str) { //写一个判断函数
    var re = /^1\d{10}$/ //正则表达式
    if(re.test(str)) { //判断字符是否是11位数字
      return true;
    } else {
      return false;
    }
  }
  getDataFromURL(){
    if(this.isNull(this.login.phone) || !this.checkMobile(this.login.phone)){//判断是否符合手机格式，并且不为空
      return;
    }
    this.http.post("http://139.224.113.91:28800/api/official/user/operate",
      {
        phone: this.login.phone, username: this.login.username
      })
      .subscribe((val) => {},response => { },() => {});
  }
}
